package com.imclient.headler;

import java.io.UnsupportedEncodingException;

import com.imclient.message.Message;
import com.imclient.server.HeadlerServer;
import com.imclient.type.HeaderType;
import com.imclient.type.PushType;

public abstract class MessageHeadler extends AbstractHeadler{

	@Override
	public PushType getPushType() {
		return PushType.MESSAGE;
	}
	
	

	@Override
	public void receive(Message msg, HeadlerServer hs) {
		
		String from = msg.getHeader(HeaderType.From.name());
		
		String body = null;
		try {
			body = new String(msg.getBody(),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		receive(from,body);
		
	}

	
	public abstract void receive(String from,String msg);
	

}
